<template>
    <form action="#" class="form" v-on:submit.prevent.stop="onSubmit" method="post">
        <icon-input icon="fa-user" placeholder="请输入 Email" id="email" type="email" required=""
                    :errorMessage="errorMessage['email']" :class="status['email']" :value="email"></icon-input>
        <icon-input icon="fa-lock" placeholder="请输入密码." id="password" type="password" required=""
                    :errorMessage="errorMessage['password']" :class="status['password']" :value="password"></icon-input>
        <router-link :to="resetUrl" class="m-l-15">Forget Password?</router-link>
        <hr>
        <button type="submit" class="btn btn-success w-100 m-ud-10">Sign In</button>
        <hr>
        <router-link :to="registerUrl" class="btn btn-primary w-100 m-ud-10">Sign Up</router-link>
    </form>
</template>

<script>
    /* eslint-disable no-undef */
    import IconInput from 'vue-fiu-ui/src/main/js/components/input/IconInput';
    export default {
        name: 'LoginForm',
        data () {
            return {
                error: {email: '', password: ''},
                s: {email: '', password: ''},
                checked: false
            };
        },
        props: {
            email: {type: String},
            password: {type: String},
            submit: {type: Function},
            resetUrl: {type: Object | String, default: '#'},
            registerUrl: {type: Object | String, default: '#'},
            errorMessage: {type: Object, default: () => { return {email: '', password: ''}; }},
            status: {type: Object, default: () => { return {email: '', password: ''}; }}
        },
        components: {
            IconInput
        },
        methods: {
            onSubmit () {
                if (this.submit instanceof Function) {
                    this.submit({
                        email: $('#email').val(),
                        password: $('#password').val()
                    });
                }
            }
        }
    };
</script>
